package com.geh.learn.timmer;

import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;

public class ExecuteTest {

    static ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();

    public static Integer test = 0;

    public static int[] testRandomTime = {2, 5, 8, 10, 30, 32, 34, 35, 40, 42, 47, 48, 55, 56, 58, 63, 65, 66, 75, 76, 79, 81, 84, 85, 88, 90, 91, 95, 97, 102, 104, 109, 118, 119, 121, 127, 131, 132, 137, 138, 143, 145, 146, 152, 153, 155, 157, 159, 161, 162, 171, 174, 175, 180, 181, 182, 183, 185, 186, 189, 191, 195, 200, 204, 208, 209, 212, 215, 218, 219, 224, 227, 231, 233, 234, 235, 240, 246, 248, 249, 251, 253, 254, 255, 260, 264, 265, 269, 270, 277, 278, 279, 282, 283, 289, 291, 292, 296, 297, 298, 304, 305, 307, 310, 311, 312, 313, 314, 321, 322, 323, 324, 331, 334, 336, 338, 344, 347, 348, 350, 352, 357, 362, 363, 364, 366, 375, 378, 381, 382, 383, 386, 387, 393, 399, 403, 404, 409, 415, 418, 420, 422, 424, 427, 429, 431, 432, 433, 434, 436, 443, 445, 446, 450, 456, 458, 460, 466, 469, 472, 476, 477, 478, 480, 481, 483, 484, 485, 487, 491, 498, 499, 500, 504, 505, 508, 518, 520, 523, 525, 532, 535, 536, 537, 538, 540, 542, 545, 546, 547, 548, 553, 558, 559, 578, 580, 585, 587, 589, 590, 591, 592, 594, 601, 605, 606, 607, 610, 612, 617, 618, 623, 625, 633, 634, 637, 642, 645, 647, 652, 655, 656, 663, 664, 667, 668, 671, 676, 679, 681, 683, 687, 688, 689, 691, 695, 701, 705, 706, 716, 720, 726, 728, 730, 731, 732, 733, 734, 735, 737, 739, 745, 746, 748, 753, 756, 757, 762, 763, 764, 770, 771, 772, 774, 775, 776, 778, 779, 782, 784, 785, 786, 787, 791, 796, 798, 799, 800, 802, 803, 809, 810, 816, 821, 823, 824, 825, 828, 832, 836, 838, 839, 846, 847, 849, 854, 855, 857, 858, 859, 860, 868, 870, 871, 878, 881, 883, 886, 890, 893, 894, 896, 897, 899, 901, 907, 908, 912, 917, 924, 925, 927, 937, 940, 943, 946, 947, 949, 956, 957, 958, 959, 960, 961, 969, 970, 971, 976, 980, 981, 990, 994, 995, 997, 998, 1000, 1002, 1004, 1010, 1011, 1014, 1017, 1018, 1025, 1031, 1032, 1035, 1036, 1037, 1040, 1041, 1042, 1044, 1049, 1052, 1055, 1058, 1059, 1062, 1064, 1068, 1073, 1074, 1075, 1079, 1080, 1083, 1085, 1094, 1098, 1100, 1102, 1106, 1109, 1111, 1112, 1116, 1117, 1120, 1125, 1128, 1129, 1132, 1140, 1141, 1149, 1160, 1161, 1164, 1167, 1171, 1172, 1177, 1181, 1182, 1183, 1184, 1185, 1187, 1188, 1189, 1190, 1195, 1199, 1200, 1204, 1205, 1206, 1209, 1217, 1218, 1219, 1227, 1228, 1231, 1232, 1233, 1235, 1238, 1240, 1242, 1243, 1245, 1247, 1249, 1251, 1264, 1273, 1274, 1275, 1276, 1280, 1281, 1284, 1285, 1291, 1293, 1294, 1295, 1296, 1298, 1299, 1302, 1303, 1304, 1305, 1307, 1309, 1310, 1311, 1314, 1316, 1317, 1321, 1324, 1327, 1329, 1332, 1334, 1335, 1337, 1340, 1356, 1357, 1363, 1365, 1371, 1372, 1377, 1378, 1379, 1383, 1387, 1394, 1396, 1398, 1401, 1406, 1408, 1409, 1415, 1416, 1419, 1422, 1423, 1424, 1425, 1432, 1435, 1436};

    // 两台机器
    // 有可能重启
    public static void main(String[] args) throws InterruptedException {

        class MyTimerTask extends TimerTask {
            @Override
            public void run() {
                test++;
                System.out.println(500 - test);
                if (test < 500) {
                    new Timer().schedule(new MyTimerTask(), (testRandomTime[test + 1] - testRandomTime[test]) * 100);
                } else {
                    System.exit(0);
                }

            }
        }

        new Timer().schedule(new MyTimerTask(), 300);

        Thread.sleep(1000 * 60 * 60);
    }

}
